package chapter5.section5;

//程序5-10：static成员变量的应用
public class Circle {
    public static final double PI = 3.1415926;//类成员变量
    private final double r;//圆的半径，实例成员变量

    //构造方法
    public Circle(double r) {
        super();
        this.r = r;
    }

    public static void main(String[] args) {
        Circle c1 = new Circle(10);
        System.out.println("c1的面积是" + c1.getArea());
        Circle c2 = new Circle(8);
        System.out.println("c2的面积是" + c2.getArea());
    }

    public double getArea() {
        return PI * r * r;
    }
}  
